import { request } from 'umi';

// 更新商品分类
export async function getProductCategory(params = {}) {
  return request(`${window.API_BASE_URL}/admin/product/category/list`, {
    method: 'GET',
    params,
  });
}

// 更新商品分类
export async function createProductCategory(data) {
  return request(`${window.API_BASE_URL}/admin/product/category`, {
    method: 'POST',
    data,
  });
}

// 更新商品分类
export async function updateProductCategory(data) {
  return request(`${window.API_BASE_URL}/admin/product/category/${data.id}`, {
    method: 'PUT',
    data,
  });
}

// 删除商品分类
export async function deleteProductCategory(id) {
  return request(`${window.API_BASE_URL}/admin/product/category/${id}`, {
    method: 'DELETE',
  });
}

// 获取商品列表
export async function getProductList(params = {}) {
  return request(`${window.API_BASE_URL}/admin/product/list`, {
    method: 'GET',
    params,
  });
}

// 创建商品
export async function createProduct(data) {
  return request(`${window.API_BASE_URL}/admin/product`, {
    method: 'POST',
    data,
  });
}

// 更新商品
export async function updateProduct(data) {
  return request(`${window.API_BASE_URL}/admin/product/${data.id}`, {
    method: 'PUT',
    data,
  });
}

// 获取商品详情
export async function getProductDetail(id) {
  return request(`${window.API_BASE_URL}/admin/product/${id}`, {
    method: 'GET',
  });
}

// 获取商品详情
export async function deleteProduct(id) {
  return request(`${window.API_BASE_URL}/admin/product/${id}`, {
    method: 'DELETE',
  });
}

// 获取商品属性列表
export async function getProductAttributeList(params = {}) {
  return request(`${window.API_BASE_URL}/admin/product/attribute/list`, {
    method: 'GET',
    params,
  });
}

// 创建商品属性
export async function createProductAttribute(data) {
  return request(`${window.API_BASE_URL}/admin/product/attribute`, {
    method: 'POST',
    data,
  });
}

// 更新商品属性
export async function updateProductAttribute(data) {
  return request(`${window.API_BASE_URL}/admin/product/attribute/${data?.id}`, {
    method: 'PUT',
    data,
  });
}

// 删除商品属性
export async function deleteProductAttribute(id) {
  return request(`${window.API_BASE_URL}/admin/product/attribute/${id}`, {
    method: 'DELETE',
  });
}

// 获取商品标签列表
export async function getProductTagList(params = {}) {
  return request(`${window.API_BASE_URL}/admin/product/tag/list`, {
    method: 'GET',
    params,
  });
}

// 创建商品标签
export async function createProductTag(data) {
  return request(`${window.API_BASE_URL}/admin/productTag`, {
    method: 'POST',
    data,
  });
}

// 更新商品标签
export async function updateProductTag(data) {
  return request(`${window.API_BASE_URL}/admin/productTag/${data.id}`, {
    method: 'PUT',
    data,
  });
}

// 删除商品标签
export async function deleteProductTag(id) {
  return request(`${window.API_BASE_URL}/admin/productTag/${id}`, {
    method: 'DELETE',
  });
}
